﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using ZOVNP.Model.Abstracts;

namespace ZOVNP.Engine
{
    internal class EngineAdder : IEngineAdder
    {
        #region Поля

        private ZOVNPEngine engine;

        #endregion

        #region Конструкторы

        internal EngineAdder(ZOVNPEngine Engine)
        {
            engine = Engine;
        }

        #endregion

        #region Методы

        public ICustomer CreateCustomer()
        {
            var result = Create<Customer>();
            result.ID = Guid.NewGuid();
            return result;
        }

        public IOrderItem CreateOrderItem()
        {
            var result = Create<OrderItem>();
            result.ID = Guid.NewGuid();
            return result;
        }

        public IOrderPart CreateOrderPart()
        {
            var result = Create<OrderPart>();
            result.ID = Guid.NewGuid();
            return result;
        }

        public IOrder CreateOrder()
        {
            var result = Create<Order>();
            result.ID = Guid.NewGuid();
            return result;
        }

        private T Create<T>() where T : DomainObject, new()
        {
            var result = new T();
            result.New = true;
            return result;
        }

        #endregion

    }
}
